package tcu.ead2021.watermanage.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;
import tcu.ead2021.watermanage.entity.Drink;
import tcu.ead2021.watermanage.entity.Result;
import tcu.ead2021.watermanage.service.DrinkService;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/drink")
public class DrinkController {

    private final DrinkService drinkService;

    @GetMapping
    public Result<List<Drink>> FindAll(){
        return Result.ok(this.drinkService.FindAll());
    }

    @PostMapping
    public Result<Drink> AddDrink(Drink drink){

        this.drinkService.addOne(drink);
        return Result.ok(drink);
    }
}
